package system;

import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.swing.JOptionPane;

import connect.connect;

public class Constant {
 
	  public static String userName;//�û���
	  
	  public static String Name;
	  public static String Level;

	  
	  @SuppressWarnings("finally")
	public static String getName(){
		  try {
				String sql = "select Name from Users where UserName="+userName+"";
				Connection conn = connect.getConnection();
				Statement stat = conn.createStatement();
				ResultSet rs = stat.executeQuery(sql);
				while (rs.next()) { // ����ȡ�����
//					JOptionPane.showMessageDialog(null, "+++++++"); //����
					Name=rs.getString(1);
				}
				stat.close();
				conn.close();
			} catch (SQLException sqlex) {
				sqlex.printStackTrace();
			} catch (IOException e1) {
				e1.printStackTrace();
			}finally{
				return Name;
			}
	  }
	  @SuppressWarnings("finally")
	public static String getLevel(){
		  try {
				String sql = "select Lv from Users where UserName="+userName+"";
				Connection conn = connect.getConnection();
				Statement stat = conn.createStatement();
				ResultSet rs = stat.executeQuery(sql);
				while (rs.next()) { // ����ȡ�����
//					JOptionPane.showMessageDialog(null, "+++++++"); //����
					Level=rs.getString(1);
				}
				stat.close();
				conn.close();
			} catch (SQLException sqlex) {
				sqlex.printStackTrace();
			} catch (IOException e1) {
				e1.printStackTrace();
			}finally{
				return Level;
			}
	  }
//
}
